// pages/opt_user_admin/opt_page/lease_return/hospital_lease_info/hospital_lease_info.js
var app = getApp()
//常量数据配置
var ConstantData = require('../../../../../../common/constant_data.js')
var uitl = require('../../../../../../utils/util.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    leaseList:[],
    hospitalName:"",
    selTypeName:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var leaseHospitalId = options.leaseHospitalId;
    var leaseType = options.leaseType;
    var hospitalName = options.hospitalName;
    this.setData({
      hospitalName:hospitalName,
      selTypeName: leaseType == 1 ? "租出其他医院轮椅":"其他医院归位桩租出轮椅"
    })
    if(leaseType == 1) {      
      //租出其他医院轮椅
      this.getLeaseOtherChair(leaseHospitalId);
    }else if(leaseType == 2) {
      //其他医院归位桩租出轮椅
      this.getLeaseOtherPiple(leaseHospitalId);
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  getLeaseOtherChair: function (leaseHospitalId) {
     
    var that = this;
    app.executeRequest(function (header) {
      wx.request({
        url: ConstantData.CONSTATNT_DATA.BASE_URL + '/lease_admin/lease/lease_other_chair',
        header: header,
        data:{
          eqTid: leaseHospitalId
        },
        success: function (res) {
          console.log("leaseList---->", res);
          if (res.data.result === 0) {   
            var list = new Array();
            let chairList = res.data.data;
            for(let i=0;i<chairList.length;i++) {
              chairList[i].first_open_time = uitl.timestampToTime(chairList[i].first_open_time);
              chairList[i].last_open_time = uitl.timestampToTime(chairList[i].last_open_time);
            }         
            that.setData({
              leaseList: chairList,
            })
          }
        }
      })
    });  

  },
  getLeaseOtherPiple: function (leaseHospitalId) {

  }
})